package dfbz.demo;

import java.util.List;

public class Test {
    private static List<String> list=List.of("admin", "lucy", "rose", "mike");

    public static void main(String[] args) {
//        Collections.addAll(hashSet, "admin", "lucy", "rose", "mike");
        try {
//            demo01("mike");
            new Test().demo01("mike");
            System.out.println("注册成功");
        } catch (ResgisterException e) {
            e.printStackTrace();
            System.out.println(e);
        }finally {
            System.out.println("内存释放");
        }
    }
//
    public void demo01(String string) throws ResgisterException {
        if (list.contains(string)) {
            throw new ResgisterException("用户已被注册");
        }
    }
}
